#ifndef _OH_CONTAINER_H
#define	_OH_CONTAINER_H
/*******************************************************************************
 ** Name: container.hpp                                                       **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the license.txt within              **
 ** this distribution or at http://www.munixos.net/licensing.                 **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $$HOME/license.txt.                  **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// Modified $Date: 2011-11-24 00:07:02 -0700 (Thu, 24 Nov 2011) $ by $Author: unknown $
#define _container_h_ID    "$Id: container.hpp 63608 2011-11-24 07:07:02Z unknown $"

#include <iostream>
#include <vector>
#include "item.hpp"
#include "character.hpp"

#define DEFAULT_DOOR_HP     75
#define DEFAULT_CAPACITY	75

// Container flags
#define CONTAINER_IS_OPEN	0x01
#define CONTAINER_LOCKED	0x02
#define CONTAINER_PICKABLE	0x04

//! @class Container
//! @brief The base container class.
#pragma db object table("containers")
class Container : public Item
{
public:
	Container() { }
    Container(const std::string &n);	// should not be allowed to be called.
    Container(const Container& orig);
    virtual ~Container();

    virtual std::string    TypeToStr() { return "Container"; }

    ushort &		OpenDC() { return open_dc; }
    entity_t &		Key() { return key; }
    ushort &		Capacity() { return capacity; }
    bool			Open() { return _flags & CONTAINER_IS_OPEN; }
    bool			Locked() { return _flags & CONTAINER_LOCKED; }
    bool			Pickable() { return _flags & CONTAINER_PICKABLE; }

    inline void     AddItem(boost::shared_ptr<Item> & o) { contains.push_back(o); }
    inline void     RemoveItem(entity_t);
    Item::pointer & GetItem(entity_t);

private:
    std::vector<Item::pointer> contains;
    ushort             	open_dc;
    entity_t			key;	// if key, this is the id
    ushort				capacity;
};


///////////////////////////////[ Region
// Region flags
#define REGION_PVP_ENA		0x01

//! @class Region
//! @brief Rooms can be grouped with like rooms called regions
// Should regions have portals to other regions?
#pragma db object table("regions")
class Region
{
public:
	Region() { _id = _flags = 0; }
	Region(const Region &);

	// Getters
	const entity_t		ID() const { return _id; }
	const std::string &	Name() const { return _name; }
	const std::string &	Desc() const { return _desc; }
	const unsigned int Flags()const  { return _flags; }

	// Setters
	void	Name(const std::string & n) { _name = n; }
	void	Desc(const std::string & d) { _desc = d; }



private:
	friend class odb::access;
	#pragma db id auto
	entity_t		_id;
	std::string		_name;
	std::string		_desc;
	unsigned int	_flags;
};

#define FLAG_TRAIT_VCL_EJS      0x0001    // ejection seats
#define FLAG_TRAIT_VCL_TRA      0x0002   // traction
#define FLAG_TRAIT_VCL_SEA      0x0004   // sealed
#define FLAG_TRAIT_VCL_FLA      0x0008	//<! flammable
#define FLAG_TRAIT_VCL_DEP      0x0010	//<! dependable
#define FLAG_TRAIT_VCL_UDE      0x0020
#define FLAG_TRAIT_VCL_ATV      0x0040    // 4wheeler
#define FLAG_TRAIT_VCL_ECM      0x0080    // electronic countermeasures
#define FLAG_TRAIT_VCL_COM      0x0100    // satellite comm system
#define FLAG_TRAIT_VCL_ARM      0x0200   // armored
#define FLAG_TRAIT_VCL_FLY      0x0400   // flying
#define FLAG_TRAIT_VCL_WPN      0x0800   // mounted weapons
#define FLAG_TRAIT_VCL_UPG		0x1000	 // upgradeable

// Flags
#define FLAG_REQUIRES_TRAINING	0x01

enum class VehicleTypeEnum { Car, Truck, Jeep, Tank, APC, Helicopter, Airplane, Jet, Boat };
enum class VehicleClassEnum { Treaded, Wheeled, Rotor, Jet, Propeller };
#pragma db object table("vehicles")
class Vehicle : public Container
{
public:
	Vehicle() { }
	Vehicle(const std::string & n);
	Vehicle(const Vehicle &);

	VehicleClassEnum &	VehicleClass() { return vclass; }
	VehicleTypeEnum	&	VehicleType() { return vtype; }
	unsigned int	&	VehicleTraits() { return traits; }
	int &				PilotDC() { return pilot_dc; }
	ushort &			Speed() { return speed; }

	int					RequiresTraining() { return(_flags & FLAG_REQUIRES_TRAINING); }
	void				RequiresTraining(bool t) { if (t) BMSET(_flags,FLAG_REQUIRES_TRAINING); else BMCLR(_flags,FLAG_REQUIRES_TRAINING); }

protected:
	VehicleClassEnum	vclass;
	VehicleTypeEnum		vtype;
	unsigned int		traits;
	int					pilot_dc;	// difficulty to pilot/drive/steer
	ushort				speed, speed_max;
};


#endif	/* _OH_CONTAINER_H */

